package com.sh1604.duitang.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sh1604.duitang.R;
import com.sh1604.duitang.mybean.AtricleBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * ***********************************************************
 * author: jie
 * time: 2016/7/22 21:36
 * name:
 * overview:Build.VERSION.SDK_INT:版本号
 * usage:
 * *************************************************************
 */
public class AtricleAdapter extends BaseAdapter {
    private Context mContext;
    List<AtricleBean.DataBean.ObjectListBean> mData1s;

    public AtricleAdapter(Context context,List<AtricleBean.DataBean.ObjectListBean> datas){
        this.mContext = context;
        this.mData1s = datas;
    }
    @Override
    public int getCount() {
        return mData1s == null ? 0 : mData1s.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AtricleHolder holder = null;
        if (convertView==null){
            holder = new AtricleHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_atr, parent,false);
            holder.atr_iv = (ImageView) convertView.findViewById(R.id.iv_store1);
            holder.atr_tv1 = (TextView) convertView.findViewById(R.id.tv_store_top2);
            holder.atr_tv2 = (TextView) convertView.findViewById(R.id.tv_store_centre3);
            holder.atr_tv3 = (TextView) convertView.findViewById(R.id.tv_store_bottom4);
            convertView.setTag(holder);
        }else {
            holder = (AtricleHolder) convertView.getTag();
        }
        AtricleBean.DataBean.ObjectListBean bean = mData1s.get(position);

        Picasso.with(mContext).load(bean.getCover().getPhoto_path()).into(holder.atr_iv);
        holder.atr_tv1.setText(bean.getTitle());
        holder.atr_tv2.setText(bean.getContent());
        Log.i("mData111111s","-123-->!!!--123->!!!--123->"+bean.getVisit_count());
        holder.atr_tv3.setText(bean.getVisit_count()+"次浏览");
        return convertView;
    }

    private class AtricleHolder {
        private TextView atr_tv1,atr_tv2,atr_tv3;
        private ImageView atr_iv;
    }
}
